package com.lb.builder;

import lombok.ToString;

/**
 * @Author: 章钧
 * @Date: 2024-06-14
 * @Description:
 */
@ToString
//@Builder
public class UserInfo {
    private String id;
    private String name;
    private int age;

    private UserInfo(UserInfoBuilder builder) {
        this.id = builder.id;
        this.name = builder.name;
        this.age = builder.age;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    static class UserInfoBuilder {
        private String id;
        private String name;
        private int age;

        public UserInfoBuilder setId(String id) {
            this.id = id;
            return this;
        }

        public UserInfoBuilder setName(String name) {
            this.name = name;
            return this;
        }

        public UserInfoBuilder setAge(int age) {
            this.age = age;
            return this;
        }

        public UserInfo build() {
            return new UserInfo(this);
        }
    }

    public static void main(String[] args) {
//        UserInfo edwarder = UserInfo.builder()
//                .name("lili")
//                .age(10)
//                .build();
       UserInfo u = new UserInfoBuilder()
               .setName("lili")
               .build();
        System.out.println(u);
    }
}
